<?php

require_once "TEST/Benchmark.php";
require_once "RestRequest/rest-request-factory.php";
require_once "RestRequest/rest-request-strategy.php";

$factoryBenchmark = new Benchmark();

echo "Prototype Test<br />";

$factoryBenchmark->start();

$factory = new RestRequestFactory();

for ( $counter = 1; $counter <= 1000; $counter++) {
	$factoryRequest = $factory->CreateRequest("GET");
	$factoryResponse = $factoryRequest->makeRequest("http://localhost:8888/phprestsql/gm_group/1.xml");
	//echo $factoryResponse;
}


// benchmark timing
$factoryBenchmark->end();

try {
	echo "<p>Factory GET Time: <b>" . $factoryBenchmark->getTimeDiff() . "</b><br /><br />";
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

$strategyBenchmark = new Benchmark();

echo "Strategy Test<br />";

$strategyBenchmark->start();

for ( $counter = 1; $counter <= 1000; $counter++) {
	$context = new RESTContext(new GetRequest());
	$context->setRequest("http://localhost:8888/phprestsql/gm_group/1.xml");
	$strategyResponse = $context->execute();
	//echo  $strategyResponse;
}

$strategyBenchmark->end();

try {
	echo "<p>Strategy GET Time: <b>" . $strategyBenchmark->getTimeDiff() . "</b><br /><br />";
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

?>